package com.epam.strings.utils;

import org.apache.log4j.Logger;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Yelena_M
 * Date: 11.08.13
 * Time: 17:31
 * To change this template use File | Settings | File Templates.
 */
public class TextFileReader {

    private static final Logger LOGGER = Logger.getLogger(TextFileReader.class);

    public static BufferedReader openTextFile(String pathText) {
        PropertiesReader propertiesReader = new PropertiesReader();
        String fileName = propertiesReader.getProperties(pathText);
        BufferedReader input = null;

        try {
            input = new BufferedReader(new FileReader(fileName));
        } catch (FileNotFoundException e) {
            LOGGER.error("File \"" + fileName + "\" not found");
        }
        return input;
    }

    public static void closeTextFile(BufferedReader bufferedReader) {

        try {
            bufferedReader.close();
        } catch (IOException e) {
            LOGGER.error(e);
        }
    }
}
